﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Text;

namespace ArmoryAPI
{
    /// <summary>
    /// Represents a World of Warcraft achievement
    /// </summary>
    public class Achievement
    {
        #region Members

            private int _id;
            private String _title;
            private int _points;
            private String _description;

        #endregion

        #region Properties

            /// <summary>
            /// The unique identifier specified by Blizzard for this achievement
            /// </summary>
            public int ID
            {
                get
                {
                    return _id;
                }
            }

            /// <summary>
            /// The title of the achievement
            /// </summary>
            public String Title
            {
                get
                {
                    return _title;
                }
            }

            /// <summary>
            /// The number of achievement points allocated when this achievement is unlocked
            /// </summary>
            public int Points
            {
                get
                {
                    return _points;
                }
            }

            /// <summary>
            /// The description of the achievement
            /// </summary>
            public String Description
            {
                get
                {
                    return _description;
                }
            }

        #endregion

        #region Overriden Methods
            /// <summary>
            /// Determines whether the specified System.Object is equal to the current System.Object.
            /// </summary>
            /// <param name="obj">The System.Object to compare with the current System.Object</param>
            /// <returns>True if the specified SYstem.Object is equal to the current System.Object; otherwise, false</returns>
            public override bool Equals(object obj)
            {
                // If comparing with an integer, check the passed integer against the ID
                if (obj.GetType() == typeof(int))
                {
                    return (this.ID == (int)obj);
                }
                else
                {
                    return base.Equals(obj);
                }
            }

            /// <summary>
            /// Return the hashcode for this Achievement
            /// </summary>
            /// <returns>int</returns>
            public override int GetHashCode()
            {
                return String.Format("ArmoryAPI.Achievement.{0}_{1}", this.ID, this.Title).GetHashCode();
            }

        #endregion

        #region Constructors

            internal Achievement(int id, String title, int points, String description)
            {
                _id = id;
                _title = title;
                _points = points;
                _description = description;
            }

            /// <summary>
            /// Constructs an empty Achievement
            /// </summary>
            public Achievement()
            {
                _id = -1;
                _title = String.Empty;
                _points = -1;
                _description = String.Empty;
            }

        #endregion
    }
}
